/*******************************************************************************
*  file    : main.cpp
*  created : 10.07.2014
*  author  : Slyshyk Oleksiy (alexSlyshyk@gmail.com)
*******************************************************************************/

#include <QApplication>
#include <QTextCodec>
#include <qlogger.hpp>
#include "windmainwindow.hpp"

namespace
{
QLogger * l = QLoggerEngine::getLogger("Core");
}

int main(int argc, char *argv[])
{
    int appRes = 0;
    QCoreApplication::setApplicationName ("wind_calc"  );
    QCoreApplication::setOrganizationName("Technomatix");

    try
        {
            QApplication a(argc, argv);
#if QT_VERSION < 0x050000
            QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
#endif
            #ifdef Q_OS_WIN
            QTextCodec::setCodecForLocale(QTextCodec::codecForName("CP-866"));
            #endif

            windMainWindow w;
#ifdef Q_OS_LINUX
            w.setWindowIcon(QIcon(QPixmap("://images/wind_vane.png")));
#endif
            w.show();

            appRes = a.exec();
        }
    catch(std::exception &e)
        {
            logError(l) << e.what();
            appRes = 5;
        }
    catch(...)
        {
            appRes = 7;
        }

    return appRes;
}
